/**
 * @param {number[]} nums
 * @return {number}
 */
var maxSubArray = function (nums) {
    let len = nums.length, res = 0, count
    for (let i = 0; i < len; i++) {
        count += nums[i]
        if (count > res) {
            res = count
        }
        if (count < 0) {
            count = 0
        }
    }
    return res
};